<?php
namespace app\index\service;


use app\index\model\ContractBuModel;
use app\index\model\ContractShiModel;
use app\index\model\DealcomModel;
use app\index\model\DeptModel;
use app\index\model\EnginBaoModel;
use app\index\model\EnginModel;
use app\index\model\EnginMuModel;
use app\index\model\EnginTempModel;
use app\index\model\EnginTingModel;
use app\index\model\EnginYueModel;
use app\index\model\IncomeEnginModel;
use app\index\model\PaymentBaoModel;
use app\index\model\PaymentEnginModel;
use app\index\model\PaymentNeifuModel;
use app\index\model\PaymentNeikouModel;
use app\index\model\UserModel;
use app\index\model\UserRoleModel;
use think\Db;
use think\facade\Config;

class EnginService extends CommonService
{
    public function get_dea_engin_mu(){
        return [
            [
                'name'=>'建设单位',
                'children'=> [
                    [
                        'name'=>'项目前期文件',
                        'children'=> [
                            ['name'=>'旗县下发上报文件', 'children'=> [
                                ['name'=>'旗县下发上报通知文件', 'children'=> []],
                                ['name'=>'乡镇、村上报项目计划申请', 'children'=> []],
                                ['name'=>'村两委班子会', 'children'=> []],
                                ['name'=>'村民代表会', 'children'=> []],
                                ['name'=>'受益村民承诺函', 'children'=> []],
                            ]],
                            ['name'=>'旗县上报项目文件', 'children'=> [
                                ['name'=>'建设任务需求报告', 'children'=> []],
                                ['name'=>'年度实施计划', 'children'=> []],
                                ['name'=>'专家评审等文件', 'children'=> []],
                            ]],
                            ['name'=>'会议纪要', 'children'=> [
                                ['name'=>'与立项有关的会议纪要情况', 'children'=> []],
                            ]],
                            ['name'=>'设计单位选择', 'children'=> [
                                ['name'=>'设计单位招投标情况', 'children'=> []],
                                ['name'=>'设计合同签订情况', 'children'=> []],
                            ]],
                            ['name'=>'设计文件', 'children'=> [
                                ['name'=>'项目初步设计', 'children'=> []],
                                ['name'=>'初步审查及批复文件', 'children'=> []],
                                ['name'=>'评审情况', 'children'=> []],
                                ['name'=>'市农牧局下达的批复', 'children'=> []],
                                ['name'=>'批复的设计图纸', 'children'=> []],
                                ['name'=>'项目概算', 'children'=> []],
                                ['name'=>'设计技术交底', 'children'=> []],
                            ]],
                            ['name'=>'论证文件', 'children'=> [
                                ['name'=>'水资源论证专项评估报告', 'children'=> []],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'开工审批文件',
                        'children'=> [
                            ['name'=>'项目组建', 'children'=> [
                                ['name'=>'项目法人组建函件', 'children'=> []],
                                ['name'=>'印章启用', 'children'=> []],
                                ['name'=>'人员任命文件情况', 'children'=> []],
                                ['name'=>'变更及审批文件', 'children'=> []],
                            ]],
                            ['name'=>'项目划分', 'children'=> [
                                ['name'=>'项目划分审批文件', 'children'=> []],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'工程建设管理文件',
                        'children'=> [
                            ['name'=>'会议文件', 'children'=> [
                                ['name'=>'工程管理相关会议文件', 'children'=> []],
                            ]],
                            ['name'=>'年度工作总结', 'children'=> [
                                ['name'=>'工程建设年度工作总结内容是否与施工进度相符', 'children'=> []],
                            ]],
                            ['name'=>'管理事记', 'children'=> [
                                ['name'=>'工程建设管理大事记情况', 'children'=> []],
                            ]],
                            ['name'=>'设计变更', 'children'=> [
                                ['name'=>'重大设计变更申请', 'children'=> []],
                            ]],
                            ['name'=>'工程结算', 'children'=> [
                                ['name'=>'工程预算', 'children'=> []],
                                ['name'=>'合同价结算等文件报告', 'children'=> []],
                            ]],
                            ['name'=>'来往函件', 'children'=> [
                                ['name'=>'通知、通报等日常管理性文件', 'children'=> []],
                                ['name'=>'一般性来往函件', 'children'=> []],
                            ]],
                            ['name'=>'事故处理', 'children'=> [
                                ['name'=>'有关质量及安全生产事故处理情况', 'children'=> []],
                            ]],
                            ['name'=>'宣传报道', 'children'=> [
                                ['name'=>'重要领导视察', 'children'=> []],
                                ['name'=>'重要活动及宣传报道文件', 'children'=> []],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'招投标合同文件',
                        'children'=> [
                            ['name'=>'招标计划', 'children'=> [
                                ['name'=>'招标计划及审批文件', 'children'=> []],
                            ]],
                            ['name'=>'招标公告及文件', 'children'=> [
                                ['name'=>'招标公告', 'children'=> []],
                                ['name'=>'招标文件', 'children'=> []],
                                ['name'=>'招标修改文件等', 'children'=> []],
                            ]],
                            ['name'=>'投标文件', 'children'=> [
                                ['name'=>'中标的投标书', 'children'=> []],
                                ['name'=>'澄清', 'children'=> []],
                                ['name'=>'修正补充文件', 'children'=> []],
                                ['name'=>'投标流程', 'children'=> []],
                            ]],
                            ['name'=>'评标报告', 'children'=> [
                                ['name'=>'评标报告', 'children'=> []],
                                ['name'=>'定标文件', 'children'=> []],
                            ]],
                            ['name'=>'中标情况', 'children'=> [
                                ['name'=>'中标通知书', 'children'=> []],
                            ]],
                            ['name'=>'合同文件', 'children'=> [
                                ['name'=>'合同书', 'children'=> []],
                                ['name'=>'合同执行', 'children'=> []],
                                ['name'=>'合同变更', 'children'=> []],
                                ['name'=>'合同台账文件', 'children'=> []],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'资金管理',
                        'children'=> [
                            ['name'=>'资金配套', 'children'=> [
                                ['name'=>'地方配套资金情况文件', 'children'=> [
                                    ['name'=>'自治区配套资金情况文件', 'children'=> []],
                                    ['name'=>'盟市配套资金情况文件', 'children'=> []],
                                    ['name'=>'旗县配套资金情况文件', 'children'=> []],
                                ]],
                                ['name'=>'群众自筹投入情况文件', 'children'=> []],
                                ['name'=>'中央投资资金情况文件', 'children'=> []],
                            ]],
                            ['name'=>'制度执行', 'children'=> [
                                ['name'=>'资金审计制度', 'children'=> []],
                                ['name'=>'资金审计', 'children'=> []],
                                ['name'=>'会计制度', 'children'=> []],
                            ]],
                            ['name'=>'资金使用情况文件', 'children'=> [
                                ['name'=>'支付详细说明文件', 'children'=> [
                                    ['name'=>'施工项目资金支付文件', 'children'=> []],
                                    ['name'=>'监理项目资金支付文件', 'children'=> []],
                                    ['name'=>'设计项目资金支付文件', 'children'=> []],
                                    ['name'=>'管理费支付文件', 'children'=> []],
                                ]],
                                ['name'=>'批复文件', 'children'=> [
                                    ['name'=>'初步设计批复文件', 'children'=> []],
                                    ['name'=>'变更设计批复文件', 'children'=> []],
                                    ['name'=>'财务审计文件', 'children'=> []],
                                    ['name'=>'工程决算报告', 'children'=> []],
                                    ['name'=>'工程量复核报告', 'children'=> []],
                                ]],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'竣工验收文件',
                        'children'=> [
                            ['name'=>'工作报告', 'children'=> [
                                ['name'=>'参建各方管理工作报告', 'children'=> []],
                            ]],
                            ['name'=>'质量报告', 'children'=> [
                                ['name'=>'质量检测报告', 'children'=> []],
                            ]],
                            ['name'=>'竣工验收文件', 'children'=> [
                                ['name'=>'分部验收申请及批复文件', 'children'=> []],
                                ['name'=>'单位验收申请及批复文件', 'children'=> []],
                                ['name'=>'初验验收申请文件批复文件', 'children'=> []],
                                ['name'=>'竣工验收申请文件批复文件', 'children'=> []],
                                ['name'=>'验收报告', 'children'=> []],
                                ['name'=>'验收证书等', 'children'=> []],
                                ['name'=>'建设单位初验报告', 'children'=> []],
                                ['name'=>'竣工验收申请', 'children'=> []],
                                ['name'=>'大事记', 'children'=> []],
                                ['name'=>'影像文件', 'children'=> []],
                                ['name'=>'其他文件', 'children'=> []],
                            ]],
                            ['name'=>'阶段验收', 'children'=> [
                                ['name'=>'阶段验收文件', 'children'=> []],
                            ]],
                            ['name'=>'工程结算', 'children'=> [
                                ['name'=>'工程量复核报告', 'children'=> []],
                                ['name'=>'财务决算报告', 'children'=> []],
                                ['name'=>'审计报告', 'children'=> []],
                            ]],
                            ['name'=>'交接手续', 'children'=> [
                                ['name'=>'工程竣工验收后相关交接', 'children'=> []],
                                ['name'=>'备案文件（管护移交 书或资产移交表）', 'children'=> []],
                            ]],
                        ],
                    ],
                ],
            ],
            [
                'name'=>'设计单位',
                'children'=> [
                    [
                        'name'=>'初步设计',
                        'children'=> [
                            ['name'=>'初步设计申请及批复', 'children'=> []],
                            ['name'=>'技术设计文件', 'children'=> []],
                            ['name'=>'设计方案审查意见及批复', 'children'=> []],
                            ['name'=>'设计交底资料', 'children'=> []],
                        ],
                    ],
                    [
                        'name'=>'设计文件',
                        'children'=> [
                            ['name'=>'设计工作报告', 'children'=> []],
                            ['name'=>'设计变更方案及批复', 'children'=> []],
                        ],
                    ],
                ],
            ],
            [
                'name'=>'监理单位',
                'children'=> [
                    ['name'=>'人员配备', 'children'=> [
                        ['name'=>'监理项目部组建函件', 'children'=> []],
                        ['name'=>'印章启用', 'children'=> []],
                        ['name'=>'监理人员资质及签字真迹', 'children'=> []],
                        ['name'=>'监理人员变更文件', 'children'=> []],
                        ['name'=>'总监任命', 'children'=> []],
                    ]],
                    ['name'=>'规划细则', 'children'=> [
                        ['name'=>'监理规划', 'children'=> []],
                        ['name'=>'大纲及报审文件', 'children'=> []],
                        ['name'=>'监理实施细则', 'children'=> []],
                    ]],
                    ['name'=>'开工文件', 'children'=> [
                        ['name'=>'合同开工通知', 'children'=> []],
                        ['name'=>'暂停施工指示', 'children'=> []],
                        ['name'=>'复工通知等文件', 'children'=> []],
                        ['name'=>'图纸会审', 'children'=> []],
                        ['name'=>'进度计划及批复', 'children'=> []],
                        ['name'=>'合同开工批复', 'children'=> []],
                        ['name'=>'分部工程开工批复', 'children'=> []],
                        ['name'=>'批复表', 'children'=> []],
                    ]],
                    ['name'=>'施工过程记录', 'children'=> [
                        ['name'=>'施工过程监理文件', 'children'=> []],
                        ['name'=>'监理日志', 'children'=> []],
                        ['name'=>'月报', 'children'=> []],
                        ['name'=>'监理平行检验', 'children'=> []],
                        ['name'=>'试验记录', 'children'=> []],
                        ['name'=>'旁站抽检文件', 'children'=> []],
                        ['name'=>'监理日记', 'children'=> []],
                        ['name'=>'监理巡视记录', 'children'=> []],
                        ['name'=>'工程质量跟踪检测试样记录', 'children'=> []],
                        ['name'=>'工程设备进场开箱验收单', 'children'=> []],
                        ['name'=>'安全检查记录', 'children'=> []],
                    ]],
                    ['name'=>'质量检测', 'children'=> [
                        ['name'=>'项目划分表', 'children'=> []],
                        ['name'=>'材料报审情况', 'children'=> []],
                        ['name'=>'机械设备进场情况', 'children'=> []],
                        ['name'=>'监理检查', 'children'=> []],
                        ['name'=>'复检', 'children'=> []],
                        ['name'=>'旁站记录', 'children'=> []],
                        ['name'=>'见证取样', 'children'=> []],
                        ['name'=>'隐蔽工程', 'children'=> []],
                        ['name'=>'分项工程', 'children'=> []],
                        ['name'=>'分部工程报验表', 'children'=> []],
                    ]],
                    ['name'=>'安全生产', 'children'=> [
                        ['name'=>'安全生产制度', 'children'=> []],
                        ['name'=>'安全生产人员培训', 'children'=> []],
                        ['name'=>'机械设备安全检查', 'children'=> []],
                    ]],
                    ['name'=>'整改文件', 'children'=> [
                        ['name'=>'监理通知单', 'children'=> []],
                        ['name'=>'回复单', 'children'=> []],
                        ['name'=>'工作联系单', 'children'=> []],
                        ['name'=>'来往函件', 'children'=> []],
                        ['name'=>'监理收、发文登记表', 'children'=> []],
                        ['name'=>'监理机构联系单', 'children'=> []],
                    ]],
                    ['name'=>'会议纪要', 'children'=> [
                        ['name'=>'监理例会', 'children'=> []],
                        ['name'=>'专题会等会议纪要', 'children'=> []],
                        ['name'=>'备忘录', 'children'=> []],
                        ['name'=>'内部会签单', 'children'=> []],
                    ]],
                    ['name'=>'总结', 'children'=> [
                        ['name'=>'监理工作报告', 'children'=> []],
                        ['name'=>'专题报告', 'children'=> []],
                    ]],
                    ['name'=>'签证审批', 'children'=> [
                        ['name'=>'变更', 'children'=> []],
                        ['name'=>'签证文件', 'children'=> []],
                        ['name'=>'变更项目价格审核表', 'children'=> []],
                        ['name'=>'变更项目价格工期确认单', 'children'=> []],
                    ]],
                    ['name'=>'支付审批', 'children'=> [
                        ['name'=>'工程量审核及工程款申请及拨付文件', 'children'=> [
                            ['name'=>'工程预付款支付证书', 'children'=> []],
                            ['name'=>'索赔审核表', 'children'=> []],
                            ['name'=>'索赔确认单', 'children'=> []],
                            ['name'=>'工程进度付款审核汇总表', 'children'=> []],
                            ['name'=>'工程进度付款证书', 'children'=> []],
                            ['name'=>'合同解除后付款证书', 'children'=> []],
                            ['name'=>'完工付款最终结清证书', 'children'=> []],
                            ['name'=>'质量保证金退还证书', 'children'=> []],
                        ]],
                    ]],
                    ['name'=>'监理例会', 'children'=> [
                        ['name'=>'监理组织的重要会议', 'children'=> []],
                        ['name'=>'培训文件', 'children'=> []],
                    ]],
                    ['name'=>'影像文件', 'children'=> [
                        ['name'=>'监理影像文件', 'children'=> []],
                    ]],
                ],
            ],
            [
                'name'=>'施工单位',
                'children'=> [
                    [
                        'name'=>'施工管理资料',
                        'children'=> [
                            ['name'=>'合同开工申报', 'children'=> [
                                ['name'=>'合同标段开工报验', 'children'=> []],
                                ['name'=>'合同标段开工审批', 'children'=> []],
                                ['name'=>'单位工程开工申请及批复', 'children'=> []],
                                ['name'=>'分部工程开工申请', 'children'=> []],
                                ['name'=>'分部工程批复文件', 'children'=> []],
                                ['name'=>'放样文件（埂线图）', 'children'=> []],
                            ]],
                            ['name'=>'施工方案', 'children'=> [
                                ['name'=>'编写内容', 'children'=> []],
                                ['name'=>'审批手续', 'children'=> []],
                                ['name'=>'修改情况', 'children'=> []],
                            ]],
                            ['name'=>'施组', 'children'=> [
                                ['name'=>'施组编写内容', 'children'=> []],
                                ['name'=>'审批手续', 'children'=> []],
                                ['name'=>'修改情况', 'children'=> []],
                            ]],
                            ['name'=>'交底', 'children'=> [
                                ['name'=>'设计技术交底四方签认及会议纪要闭环情况', 'children'=> []],
                                ['name'=>'关键工序交底纪要及闭环情况', 'children'=> []],
                            ]],
                            ['name'=>'人员配置', 'children'=> [
                                ['name'=>'施工项目部组建函件', 'children'=> []],
                                ['name'=>'印章启用', 'children'=> []],
                                ['name'=>'人员任命文件情况及证件', 'children'=> []],
                                ['name'=>'变更及批准手续', 'children'=> []],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'施工保证资料',
                        'children'=> [
                            ['name'=>'施工记录', 'children'=> [
                                ['name'=>'压实度自检记录', 'children'=> []],
                                ['name'=>'施工检验记录及报告', 'children'=> []],
                            ]],
                            ['name'=>'检测单位', 'children'=> [
                                ['name'=>'检测单位资质', 'children'=> []],
                            ]],
                            ['name'=>'材料检验', 'children'=> [
                                ['name'=>'材料进场检验情况记录', 'children'=> []],
                                ['name'=>'见证取样记录', 'children'=> []],
                                ['name'=>'检测报告', 'children'=> []],
                                ['name'=>'树木检疫报告', 'children'=> []],
                            ]],
                            ['name'=>'隐检', 'children'=> [
                                ['name'=>'隐蔽工程检查制度', 'children'=> []],
                                ['name'=>'隐蔽验收记录', 'children'=> []],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'过程控制资料',
                        'children'=> [
                            ['name'=>'施工日志', 'children'=> []],
                            ['name'=>'施工月报', 'children'=> [
                                ['name'=>'验评资料', 'children'=> []],
                                ['name'=>'验评资料', 'children'=> []],
                            ]],
                            ['name'=>'验评资料', 'children'=> [
                                ['name'=>'工序/单元工程施工质量报验单', 'children'=> []],
                                ['name'=>'梯田工程评定资料', 'children'=> []],
                                ['name'=>'土壤改良工程评定资料', 'children'=> []],
                                ['name'=>'道路工程评定资料', 'children'=> []],
                                ['name'=>'防护林工程评定资料', 'children'=> []],
                                ['name'=>'沟头防护工程评定资料', 'children'=> []],
                                ['name'=>'生物封沟工程评定资料', 'children'=> []],
                                ['name'=>'管道工程评定资料', 'children'=> []],
                                ['name'=>'首部工程评定资料', 'children'=> []],
                                ['name'=>'井房工程评定资料', 'children'=> []],
                                ['name'=>'机电设备工程评定资料', 'children'=> []],
                                ['name'=>'农田输配电工程评定资料', 'children'=> []],
                                ['name'=>'截水沟工程评定资料', 'children'=> []],
                                ['name'=>'标志碑工程评定资料', 'children'=> []],
                                ['name'=>'公示牌工程评定资料', 'children'=> []],
                            ]],
                            ['name'=>'变更签证', 'children'=> [
                                ['name'=>'设计（变更） 通知', 'children'=> []],
                                ['name'=>'有关工程变更的签证', 'children'=> []],
                            ]],
                            ['name'=>'分部验收', 'children'=> [
                                ['name'=>'分部工程工程验收申请', 'children'=> []],
                                ['name'=>'验收结论文件', 'children'=> []],
                            ]],
                        ],
                    ],
                    [
                        'name'=>'验收文件',
                        'children'=> [
                            ['name'=>'单位验收', 'children'=> [
                                ['name'=>'单位工程验收申请及批复', 'children'=> []],
                                ['name'=>'单位验收结论文件', 'children'=> []],
                            ]],
                            ['name'=>'初步验收', 'children'=> [
                                ['name'=>'初步验收报告', 'children'=> []],
                                ['name'=>'管理工作报告', 'children'=> []],
                                ['name'=>'初步验收申请及批复文件', 'children'=> []],
                            ]],
                            ['name'=>'工程验收', 'children'=> [
                                ['name'=>'合格证明书', 'children'=> []],
                                ['name'=>'工程移交文件', 'children'=> []],
                                ['name'=>'竣工验收申请及批复', 'children'=> []],
                                ['name'=>'竣工验收结论文件', 'children'=> []],
                            ]],
                            ['name'=>'竣工图', 'children'=> [
                                ['name'=>'竣工图', 'children'=> []],
                            ]],
                            ['name'=>'影像文件', 'children'=> [
                                ['name'=>'工程验收影像', 'children'=> []],
                                ['name'=>'田间道路工程影像', 'children'=> []],
                                ['name'=>'土壤改良工程影像', 'children'=> []],
                                ['name'=>'梯田工程影响', 'children'=> []],
                            ]],
                            ['name'=>'结算书', 'children'=> [
                                ['name'=>'工程结算书', 'children'=> []],
                            ]],
                        ],
                    ],
                ],
            ],
            [
                'name'=>'勘查单位',
                'children'=> [
                    ['name'=>'现勘记录', 'children'=> []],
                    ['name'=>'勘察文件', 'children'=> []],
                ],
            ],
            [
                'name'=>'运营单位',
                'children'=> [
                    ['name'=>'运营单位资质', 'children'=> [
                        ['name'=>'运营单位资质', 'children'=> []],
                        ['name'=>'运营单位营业执照', 'children'=> []],
                        ['name'=>'运营单位安全生产许可证', 'children'=> []],
                    ]],
                    ['name'=>'运营单位人员资质', 'children'=> [
                        ['name'=>'运营单位负责人证件', 'children'=> []],
                    ]],
                    ['name'=>'工程移交手续', 'children'=> [
                        ['name'=>'高标准农田建设项目工程移交单', 'children'=> []],
                    ]],
                    ['name'=>'运营单位管护方案', 'children'=> [
                        ['name'=>'运行管理工作报告', 'children'=> []],
                    ]],
                ],
            ],
            [
                'name'=>'供应商单位',
                'children'=> [
                    ['name'=>'设备供应商单位资质', 'children'=> [
                        ['name'=>'设备供应商单位资质', 'children'=> []],
                        ['name'=>'设备供应商营业执照', 'children'=> []],
                        ['name'=>'设备供应商安全生产许可证', 'children'=> []],
                    ]],
                    ['name'=>'设备检验', 'children'=> [
                        ['name'=>'原材料、中间产品进场报验单', 'children'=> []],
                        ['name'=>'设备进场质量证明文件（合格证或质量证明书）', 'children'=> []],
                        ['name'=>'设备出厂检测报告', 'children'=> []],
                    ]],
                ],
            ],
            [
                'name'=>'制造商单位',
                'children'=> [
                    ['name'=>'设备制造单位质量管理体系，设备制造计划、方案及报审文件', 'children'=> [
                        ['name'=>'设备制造单位质量管理体系', 'children'=> []],
                        ['name'=>'设备制造计划', 'children'=> []],
                        ['name'=>'方案及报审文件', 'children'=> []],
                    ]],
                    ['name'=>'原材料、外购件等质量证明及报审文件', 'children'=> [
                        ['name'=>'原材料质量证明及报审文件', 'children'=> []],
                        ['name'=>'外购件等质量证明及报审文件', 'children'=> []],
                    ]],
                    ['name'=>'设备设计、出厂验收文件', 'children'=> [
                        ['name'=>'设备设计文件', 'children'=> []],
                        ['name'=>'出厂验收文件', 'children'=> []],
                    ]],
                    ['name'=>'工艺设计、说明、规程、试验、技术报告', 'children'=> [
                        ['name'=>'工艺设计', 'children'=> []],
                        ['name'=>'说明', 'children'=> []],
                        ['name'=>'规程', 'children'=> []],
                        ['name'=>'试验', 'children'=> []],
                        ['name'=>'技术报告', 'children'=> []],
                    ]],
                    ['name'=>'设备制造探伤、检测、测试、鉴定的记录、报告', 'children'=> [
                        ['name'=>'设备制造探伤报告', 'children'=> []],
                        ['name'=>'检测报告', 'children'=> []],
                        ['name'=>'测试报告', 'children'=> []],
                        ['name'=>'鉴定的记录报告', 'children'=> []],
                    ]],
                    ['name'=>'设备设计图、竣工图', 'children'=> [
                        ['name'=>'设备设计图', 'children'=> []],
                        ['name'=>'设备竣工图', 'children'=> []],
                    ]],
                    ['name'=>'设备制造音像文件（设备制造过程各关键节点、重要部位及完工面貌等）', 'children'=> []],
                    ['name'=>'设备台账、设备图纸，出厂试验报告、产品质量合格证明、安装及使用说明、维护保养手册', 'children'=> [
                        ['name'=>'设备台账', 'children'=> []],
                        ['name'=>'出厂试验报告', 'children'=> []],
                        ['name'=>'产品质量合格证明', 'children'=> []],
                        ['name'=>'安装及使用说明', 'children'=> []],
                        ['name'=>'维护保养手册', 'children'=> []],
                    ]],
                ],
            ],
            ['name'=>'市级下发文件','children'=> []],
            ['name'=>'省级下发文件','children'=> []],
            [
                'name'=>'建设方下发文件',
                'children'=> [
                    ['name'=>'建设方下发给监理方文件及回复', 'children'=> []],
                    ['name'=>'建设方下发给施工方文件及回复', 'children'=> []],
                    ['name'=>'建设方下发给设计方文件及回复', 'children'=> []],
                    ['name'=>'建设方下发给勘察方文件及回复', 'children'=> []],
                    ['name'=>'建设方下发给运营方文件及回复', 'children'=> []],
                    ['name'=>'建设方下发给设备供应方文件及回复', 'children'=> []],
                ],
            ],
            [
                'name'=>'监理方下发文件',
                'children'=> [
                    ['name'=>'监理方上报给建设方文件及批复', 'children'=> []],
                    ['name'=>'监理方下发给施工方文件及回复', 'children'=> []],
                    ['name'=>'监理方下发给运营方文件及回复', 'children'=> []],
                    ['name'=>'监理方下发给设备供应方文件及回复', 'children'=> []],
                ],
            ],
            ['name'=>'现行法律法规','children'=> []],
        ];
    }
    public function create_dea_engin_mu($enginid, $enginname){
        $arr = $this->get_dea_engin_mu();

        $muid = EnginMuModel::insertGetId([
            'comid' => $this->userinfo['comid'],
            'enginid' => $enginid,
            'pid' => 0,
            'level' => 1,
            'name' => $enginname,
            'created_user' => $this->userinfo['id'],
            'created_at' => date('Y-m-d H:i:s'),
        ]);
        EnginMuModel::where(['id'=>$muid])->update(['parents'=>$muid]);

        foreach ($arr as $vv){
            $twoArr = $this->add_dea_mu($enginid, $vv['name'], $muid, 2, $muid);
            foreach ($vv['children'] as $vvv){
                $threeArr = $this->add_dea_mu($enginid, $vvv['name'], $twoArr['muid'], 3, $twoArr['parents']);
                foreach ($vvv['children'] as $vvvv){
                    $fourArr = $this->add_dea_mu($enginid, $vvvv['name'], $threeArr['muid'], 4, $threeArr['parents']);
                    foreach ($vvvv['children'] as $vvvvv){
                        $fiveArr = $this->add_dea_mu($enginid, $vvvvv['name'], $fourArr['muid'], 5, $fourArr['parents']);
                        foreach ($vvvvv['children'] as $vvvvvv){
                            $sixArr = $this->add_dea_mu($enginid, $vvvvvv['name'], $fiveArr['muid'], 6, $fiveArr['parents']);
                            foreach ($vvvvvv['children'] as $vvvvvvv){
                                $sevenArr = $this->add_dea_mu($enginid, $vvvvvvv['name'], $sixArr['muid'], 7, $sixArr['parents']);
                            }
                        }
                    }
                }
            }
        }
        return true;
    }


    public function add_dea_mu($enginid, $name, $pid, $level, $parents){
        $muid = EnginMuModel::insertGetId([
            'comid' => $this->userinfo['comid'],
            'enginid' => $enginid,
            'pid' => $pid,
            'level' => $level,
            'name' => $name,
            'created_user' => $this->userinfo['id'],
            'created_at' => date('Y-m-d H:i:s'),
        ]);
        $parents = $parents.','.$muid;
        EnginMuModel::where(['id'=>$muid])->update(['parents'=>$parents]);
        return [
            'muid' => $muid,
            'parents' => $parents,
        ];
    }



    public function get_engin_state(){
        return [
            0=>'未开工',
            3=>'在建',
            6=>'竣工',
        ];
    }
    public function get_engin_state_name($enginid, $state){
        $name = '';
        if($state == 0){
            $name = '未开工';
        }
        if($state == 3){
            $name = '在建';
//            $tingNew = EnginTingModel::where(['enginid'=>$enginid])->order('id DESC')->find();
//            if($tingNew && $tingNew['name'] == '停工'){
//                $name = '在建(停工)';
//            }
        }
        if($state == 6){
            $name = '竣工';
        }

        return $name;
    }
    public function get_engin_state_name_tag($enginid, $state){
        $name = '';
        if($state == 0){
            $name = '<span class="mindiancheng"></span>未开工';
        }
        if($state == 3){
            $name = '<span class="mindianlan"></span>在建';
//            $tingNew = EnginTingModel::where(['enginid'=>$enginid])->order('id DESC')->find();
//            if($tingNew && $tingNew['name'] == '停工'){
//                $name = '<span class="mindiancheng"></span>在建(停工)';
//            }
        }
        if($state == 6){
            $name = '<span class="mindianlv"></span>竣工';
        }

        return $name;
    }
    public function check_engin_name($name, $id=0){
        return !!EnginModel::where(['comid'=>$this->userinfo['comid'],'name'=>$name,'deleted_user'=>0])->where('id','neq', $id)->find();
    }


    public function check_engin_temp_name($name, $id=0){
        return !!EnginTempModel::where(['comid'=>$this->userinfo['comid'],'name'=>$name,'deleted_user'=>0,'pid'=>0])
            ->where('id','neq', $id)->find();
    }

    //判断是否是该项目的建设单位
    public function check_user_is_jian($enginid){
        if(!$this->userinfo['dealid']){
            return false;
        }
        $enjian = EnginModel::where(['id'=>$enginid])->value('jian_unit');
        if(!$enjian){
            return false;
        }
        $enjianarr = explode(',', $enjian);
        if(in_array($this->userinfo['dealid'], $enjianarr)){
            return true;
        }
        return false;
    }



    public function get_user_engin(){
        if(!$this->userinfo['dealid'] || empty($this->userinfo['dealid'])){
            return [];
        }

        $str = "find_in_set(".$this->userinfo['dealid'].",jian_unit)";
        $str .= " or find_in_set(".$this->userinfo['dealid'].",she_unit)";
        $str .= " or find_in_set(".$this->userinfo['dealid'].",kan_unit)";
        $str .= " or find_in_set(".$this->userinfo['dealid'].",shi_unit)";
        $str .= " or find_in_set(".$this->userinfo['dealid'].",li_unit)";
        $str .= " or find_in_set(".$this->userinfo['dealid'].",yun_unit)";
        $str .= " or find_in_set(".$this->userinfo['dealid'].",gong_unit)";
        $str .= " or find_in_set(".$this->userinfo['dealid'].",zhi_unit)";

        $arr = EnginModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0])->where(Db::raw($str))->column('id');
        return $arr;
    }



    public function get_dealcom_type(){
        return [
            1=>'建设单位',
            2=>'施工单位',
            3=>'勘查单位',
            4=>'设计单位',
            5=>'监理单位',
            6=>'运营单位',
            7=>'供应商单位',
            8=>'制造商单位',
        ];
    }
    public function get_dealcom_type_name($type){
        $arr = $this->get_dealcom_type();
        $str = isset($arr[$type]) ? $arr[$type]: '';
        return $str;
    }
    public function check_dealcom_name($name, $id=0){
        return !!DealcomModel::where(['comid'=>$this->userinfo['comid'],'name'=>$name,'deleted_user'=>0])->where('id','neq', $id)->find();
    }


    public function get_status(){
        return [
            0=>'待审核',
            1=>'通过',
            9=>'驳回',
        ];
    }

    public function get_status_name($status){
        $arr = $this->get_status();
        $str = isset($arr[$status]) ? $arr[$status]: '';
        return $str;
    }


    public function get_bao_status_name($data){
        $str = '';

        if($data['isjian'] > 0){
            if($data['status'] == 0){
                $str = '待审核[监理]';
            }
            if($data['status'] == 1){
                $str = '通过';
            }
            if($data['status'] == 2){
                $str = '待审核[管理员]';
            }
            if($data['status'] == 9){
                $str = '驳回';
            }
        }else{
            if($data['status'] == 0){
                $str = '待审核[管理员]';
            }
            if($data['status'] == 1){
                $str = '通过';
            }
            if($data['status'] == 9){
                $str = '驳回';
            }
        }
        return $str;
    }
    public function get_bao_status_tagname($data){
        $str = '';

        if($data['isjian'] > 0){
            if($data['status'] == 0){
                $str = '<span class="colorcheng">待审核[监理]</span>';
            }
            if($data['status'] == 1){
                $str = '<span class="colorlv">通过</span>';
            }
            if($data['status'] == 2){
                $str = '<span class="colorcheng">待审核[管理员]</span>';
            }
            if($data['status'] == 9){
                $str = '<span class="colorhong">驳回</span>';
            }
        }else{
            if($data['status'] == 0){
                $str = '<span class="colorcheng">待审核[管理员]</span>';
            }
            if($data['status'] == 1){
                $str = '<span class="colorlv">通过</span>';
            }
            if($data['status'] == 9){
                $str = '<span class="colorhong">驳回</span>';
            }
        }
        return $str;
    }


    public function get_shi_status_name($data){
        $str = '';
        if($data['isjian'] > 0){
            if($data['status'] == 0){
                $str = '待审核[监理]';
            }
            if($data['status'] == 1){
                $str = '通过';
            }
            if($data['status'] == 2){
                $str = '待审核[管理员]';
            }
            if($data['status'] == 9){
                $str = '驳回';
            }
        }else{
            if($data['status'] == 0){
                $str = '待审核[管理员]';
            }
            if($data['status'] == 1){
                $str = '通过';
            }
            if($data['status'] == 9){
                $str = '驳回';
            }
        }
        return $str;
    }


    public function get_jian_status_name($data){
        $str = '';
        if($data['status'] == 0){
            $str = '待审核[管理员]';
        }
        if($data['status'] == 1){
            $str = '通过';
        }
        if($data['status'] == 9){
            $str = '驳回';
        }
        return $str;
    }


    public function get_yue_status_name($data){
        $str = '';
        if($data['isjian'] > 0){
            if($data['status'] == 0){
                $str = '待审核[监理]';
            }
            if($data['status'] == 1){
                $str = '通过';
            }
            if($data['status'] == 2){
                $str = '待审核[管理员]';
            }
            if($data['status'] == 9){
                $str = '驳回';
            }
        }else{
            if($data['status'] == 0){
                $str = '待审核[管理员]';
            }
            if($data['status'] == 1){
                $str = '通过';
            }
            if($data['status'] == 9){
                $str = '驳回';
            }
        }
        return $str;
    }






    // 1、 施工单位、勘察、设计单位的资料：  提交 → 监理单位的监理  → 管理员
    // 2、 施工单位、勘察、设计单位， 运营单位 供应商单位 制造商单位 的资料：  提交 → 监理单位的监理  → 管理员
    public function check_want_lishen($enginid){
        if($this->cominfo['isjian'] > 0){
            $engininfo = EnginModel::where(['id'=>$enginid])->find();
            $wantArr = [];
            $shi_unit_arr = explode(',',$engininfo['shi_unit']);
            $kan_unit_arr = explode(',',$engininfo['kan_unit']);
            $she_unit_arr = explode(',',$engininfo['she_unit']);
            $yun_unit_arr = explode(',',$engininfo['yun_unit']);
            $gong_unit_arr = explode(',',$engininfo['gong_unit']);
            $zhi_unit_arr = explode(',',$engininfo['zhi_unit']);
            $wantArr = array_unique(array_merge($wantArr, $shi_unit_arr, $kan_unit_arr, $she_unit_arr, $yun_unit_arr, $gong_unit_arr, $zhi_unit_arr));
            if(in_array($this->userinfo['dealid'], $wantArr)){
                return true;
            }
        }
        return false;
    }
    public function check_is_lishen($enginid){
        $li_unit = EnginModel::where(['id'=>$enginid])->value('li_unit');
        $li_unit_arr = explode(',', $li_unit);
        if(in_array($this->userinfo['dealid'], $li_unit_arr)){
            return true;
        }
        return false;
    }
    public function check_is_jianshen($enginid){
        $jian_unit = EnginModel::where(['id'=>$enginid])->value('jian_unit');
        $jian_unit_arr = explode(',', $jian_unit);
        if(in_array($this->userinfo['dealid'], $jian_unit_arr)){
            return true;
        }
        return false;
    }
    public function check_is_guanshen(){
        $roleidArr = UserRoleModel::where('id','in',$this->userinfo['roleid'])->group('type')->column('type');
        if(in_array(1, $roleidArr)){
            return true;
        }
        return false;
    }
    public function get_lishen_engin(){
        if(!$this->userinfo['dealid'] || empty($this->userinfo['dealid'])){
            return [];
        }
        $str = "find_in_set(".$this->userinfo['dealid'].",li_unit)";
        $arr = EnginModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0])->where(Db::raw($str))->column('id');
        return $arr;
    }

    public function get_jian_unit_engin(){
        if(!$this->userinfo['dealid'] || empty($this->userinfo['dealid'])){
            return [];
        }
        $str = "find_in_set(".$this->userinfo['dealid'].",jian_unit)";
        $arr = EnginModel::where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0])->where(Db::raw($str))->column('id');
        return $arr;
    }


    public function get_guanuser(){
        $roleidArr = UserRoleModel::where(['type'=>1,'deleted_user'=>0])->column('id');
        if(!$roleidArr){
            return [];
        }

        $str = "";
        foreach ($roleidArr as $roleid){
            if(empty($str)){
                $str .= "find_in_set(".$roleid.",roleid)";
            }else{
                $str .= "or find_in_set(".$roleid.",roleid)";
            }
        }
        return UserModel::where(['deleted_user'=>0])->where(Db::raw($str))->group('id')->column('id');
    }





    public function get_engin_mu_xmselect($pid=0, $enginid){
        $data = EnginMuModel::field('id,id as value,name as title,name')
            ->where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'pid'=>$pid,'enginid'=>$enginid])
            ->order('ismu ASC, sort ASC,id ASC')->select()->toArray();
        foreach ($data as &$item){
            $item['children'] = $this->get_engin_mu_xmselect($item['id'], $enginid);
        }
        return $data;
    }
    public function get_engin_mu_xmselect_xiang($pid=0, $enginid){
        $data = EnginMuModel::field('id,id as value,name as title,name,level,auth')
            ->where(['comid'=>$this->userinfo['comid'],'deleted_user'=>0,'pid'=>$pid,'enginid'=>$enginid,'ismu'=>0])
            ->order('ismu ASC, sort ASC,id ASC')->select()->toArray();
        foreach ($data as &$item){
            $item['auth'] = explode(',', $item['auth']);
            $item['children'] = $this->get_engin_mu_xmselect_xiang($item['id'], $enginid);
        }
        return $data;
    }
    public function get_engin_mu_sons($enginid, $pid=0, $sppaar=[],$status=[1]){
        $data = EnginMuModel::field('id,pid,name as title,parents,ismu,ext,size,oripath,encpath')
            ->where(['comid'=>$this->userinfo['comid'],'pid'=>$pid,'enginid'=>$enginid,'deleted_user'=>0])
            ->order('ismu ASC, sort ASC,id ASC')->select()->toArray();
        foreach ($data as &$item){
            if(in_array($item['id'], $sppaar)){
                $item['spread'] = true;
            }

            $parentsName = $this->get_mu_quanname($item['parents'], 1);
            $item['basicData'] = [
                'id'=>$item['id'],
                'pid'=>$item['pid'],
                'name'=>$item['title'],
                'ismu'=>$item['ismu'],
                'part'=>'dept',
                'parentsName'=>$parentsName,
                'ext'=>$item['ext'],
                'size'=>$item['size'],
                'oripath'=>$item['oripath'],
                'encpath'=>$item['encpath'],
            ];
            if($item['ismu'] > 0){
                $item['basicData']['noicon'] = 1;
                $item['title'] = '<span class="colorhong">【模板】</span>'.$item['title'];
            }


            $sonsArr = EnginMuModel::where(Db::raw("find_in_set(".$item['id'].",`parents`)"))->where(['enginid'=>$enginid])->column('id');
            $baonums = EnginBaoModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$enginid,'deleted_user'=>0])
                ->where('status','in',$status)->where('muid','in',$sonsArr)->count();

            $item['title'] = $item['title'].'（<span class="colorlv">'.$baonums.'</span>）';
            $item['children'] = $this->get_engin_mu_sons($enginid, $item['id'], $sppaar,$status);
        }
        return $data;
    }
    public function get_engin_mu_sonid($enginid, $pid=0){
        $arr = [$pid];

        $seaArr = [$pid];
        while (count($seaArr) > 0) {
            $huanArr = [];
            foreach ($seaArr as $sonid){
                $son = EnginMuModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$enginid,'pid'=>$sonid,'deleted_user'=>0])->column('id');
                foreach ($son as $vv_sonid){
                    $huanArr[] = $vv_sonid;
                    $arr[] = $vv_sonid;
                }
            }
            $seaArr = $huanArr;
        }
        return $arr;
    }



    public function get_mu_quanname_byid($muid){
        $parents = EnginMuModel::where(['id'=>$muid])->value('parents');
        return $this->get_mu_quanname($parents);
    }
    public function get_mu_quanname($parents='0', $type=0){
        $data = EnginMuModel::where('id','in',$parents)->order('level ASC')->column('name');
        return implode(' / ', $data);
    }


    public function get_mu_shang_arr($muid){
        $list = [];
        $parents = EnginMuModel::where(['id'=>$muid])->value('parents');
        $data = EnginMuModel::field('id,name,pid')->where('id','in',$parents)->order('level ASC')->select()->toArray();
        foreach ($data as $vvv) {
            if($vvv['pid'] == 0){
                $list[] = ['id'=>'0', 'name'=>'/'];
            }else{
                $list[] = ['id'=>$vvv['id'], 'name'=>'/'.$vvv['name']];
            }
        }
        return $list;
    }
    public function get_mu_shang_quanauth($muid){
        $arr = [];
        $parents = EnginMuModel::where(['id'=>$muid])->value('parents');
        $data = EnginMuModel::where('id','in',$parents)->column('auth');
        foreach ($data as $vv){
            $ddArr = explode(',', $vv);
            foreach ($ddArr as $vvvv){
                if($vvvv){
                    $arr[] = $vvvv;
                }
            }
        }
        $arr = array_unique($arr);
        return $arr;
    }


    public function check_engin_mu_name($name, $pid=0, $enginid, $id=0){
        $exist = true;
        $num = 1;
        while ($exist) {
            $info = EnginMuModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$enginid,'pid'=>$pid,'name'=>$name,'deleted_user'=>0])
                ->where('id','neq', $id)->find();
            if($info){
                $name = $name.'['.$num.']';
                $exist = true;
            }else{
                $exist = false;
            }
        }
        return $name;
    }




    public function check_temp_name($name, $pid=0, $id=0){
        $exist = true;
        $num = 1;
        while ($exist) {
            $info = EnginTempModel::where(['comid'=>$this->userinfo['comid'],'pid'=>$pid,'name'=>$name,'deleted_user'=>0,'ismu'=>0])
                ->where('id','neq', $id)->find();
            if($info){
                $name = $name.'['.$num.']';
                $exist = true;
            }else{
                $exist = false;
            }
        }
        return $name;
    }


    public function get_engin_ting_dt($enginid){
        $data = [];
        $tingList = EnginTingModel::where(['enginid'=>$enginid])->select()->toArray();
        foreach ($tingList as $item){
            for ($i=strtotime($item['startdt']); $i<=strtotime($item['enddt']); $i+=86400){
                $dt = date("Y-m-d", $i);
                $data[] = $dt;
            }
        }
        return array_unique($data);
    }
    public function get_engin_shi_yinginfo($enginid){
        $data = [];
        $engininfo = EnginModel::where(['id'=>$enginid])->find();
        $startdt = get_cur_dt($engininfo['startdt']);
        $enddt = get_cur_dt($engininfo['enddt']);
        if(empty($enddt) || $enddt > date("Y-m-d")){
            $enddt = date("Y-m-d");
        }
        if(!$startdt || $startdt > $enddt){
            return $data;
        }

        $tingArr = $this->get_engin_ting_dt($enginid);

        for ($i=strtotime($startdt); $i<=strtotime($enddt); $i+=86400){
            $dt = date("Y-m-d", $i);
            if(!in_array($dt, $tingArr)){
                $data[] = $dt;
            }
        }
        $data = array_unique($data);
        return $data;
    }
    public function get_dt_is_kaijun($engininfo, $seadt){
        $startdt = get_cur_dt($engininfo['startdt']);
        $enddt = get_cur_dt($engininfo['enddt']);
        if(empty($enddt) || $enddt > date("Y-m-d")){
            $enddt = date("Y-m-d");
        }
        if(!$startdt || $startdt > $enddt){
            return false;
        }

        if($seadt >= $startdt && $seadt <= $enddt){
            return true;
        }

        return false;
    }


    public function get_engin_yue_chanfee($enginid){
        return EnginYueModel::where(['enginid'=>$enginid,'status'=>1,'deleted_user'=>0])->sum('chanfee');
    }



















    public function create_engin_temp_info($muid, $tempid, $enginid){
        $muid_info = EnginMuModel::where(['id'=>$muid])->find();
        $tempid_info = EnginTempModel::where(['id'=>$tempid])->find();

        $tempinfo = EnginTempModel::where(['deleted_user'=>0,'pid'=>$tempid])->order('ismu ASC,sort ASC,id ASC')->select()->toArray();
        foreach ($tempinfo as $kk=>$item){
            $ins = [];
            $ins['comid'] = $item['comid'];
            $ins['enginid'] = $enginid;
            $ins['pid'] = $muid_info['id'];
            $ins['parents'] = $muid_info['parents'];
            $ins['level'] = $muid_info['level'] + 1;
            $ins['sort'] = (int)$kk + 1;
            $ins['ismu'] = $item['ismu'];
            $ins['name'] = $item['name'];
            $ins['ext'] = $item['ext'];
            $ins['size'] = $item['size'];
            $ins['oripath'] = $item['oripath'];
            $ins['created_user'] = $this->userinfo['id'];
            $ins['created_at'] = date('Y-m-d H:i:s');
            $ins_id = EnginMuModel::insertGetId($ins);

            $newParents = $ins['parents'].','.$ins_id;
            $encpath =  encrypt($ins_id, 'E', Config::get('service.info_key'));
            EnginMuModel::where(['id'=>$ins_id])->update(['encpath'=>$encpath,'parents'=>$newParents]);

            $this->create_engin_temp_info($ins_id, $item['id'], $enginid);
        }
    }



    public function get_temp_sons($tempid, $sppaar=[]){
        $data = EnginTempModel::field('id,pid,name as title, parents,ismu,ext,size,oripath,encpath')
            ->where(['comid'=>$this->userinfo['comid'],'pid'=>$tempid,'deleted_user'=>0])
            ->order('ismu ASC, sort ASC,id ASC')->select()->toArray();
        foreach ($data as &$item){
            if(in_array($item['id'], $sppaar)){
                $item['spread'] = true;
            }
            $parentsName = $this->get_temp_quanname($item['parents'], 1);
            $item['basicData'] = [
                'id'=>$item['id'],
                'pid'=>$item['pid'],
                'name'=>$item['title'],
                'ismu'=>$item['ismu'],
                'part'=>'dept',
                'parentsName'=>$parentsName,
                'ext'=>$item['ext'],
                'size'=>$item['size'],
                'oripath'=>$item['oripath'],
                'encpath'=>$item['encpath'],
            ];
            if($item['ismu'] > 0){
                $item['basicData']['noicon'] = 1;
                $item['title'] = '<span class="colorhong">【模板】</span>'.$item['title'];
            }
            $item['children'] = $this->get_temp_sons($item['id'], $sppaar);
        }
        return $data;
    }
    public function get_temp_quanname($parents='0', $type=0){
        $data = EnginTempModel::where('id','in',$parents)->order('level ASC')->column('name');
        return implode(' / ', $data);
    }




    //1、上报文件新增（无需审核的）
    //2、上报文件审核通过【包含批量审核】
    //3、上报文件删除
    //4、文件目录【及其文件模板】删除
    //5、文件目录复制及其剪切
    public function set_engin_baonum($muid){
        $muInfo = EnginMuModel::where(['id'=>$muid])->find();
        if(!$muInfo){
            return true;
        }

        if($muInfo['deleted_user'] > 0){
            $this->set_bao_dan($muInfo['pid']);
        }else{
            $this->set_bao_dan($muInfo['id']);
        }
        return true;
    }
    public function set_bao_dan($muid){
        $muInfo = EnginMuModel::where(['id'=>$muid])->find();
        $sonsArr = EnginMuModel::where(Db::raw("find_in_set(".$muid.",`parents`)"))
            ->where(['enginid'=>$muInfo['enginid'],'deleted_user'=>0])->column('id');

        $baonum = EnginBaoModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$muInfo['enginid'],'deleted_user'=>0])
            ->where('status','=',1)->where('muid','in',$sonsArr)->count();

        $baoshennum = EnginBaoModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$muInfo['enginid'],'deleted_user'=>0])
            ->where('status','in',[0,1])->where('muid','in',$sonsArr)->count();

        EnginMuModel::where(['id'=>$muid])->update([
            'baonum' => $baonum,
            'baoshennum' => $baoshennum,
        ]);

        if($muInfo['pid'] > 0){
            $this->set_bao_dan($muInfo['pid']);
        }
        return true;
    }







}
